package tmt.usercenter.web.repository;


import com.tmt.jpa.jpaservice.ITmtBaseRepo;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import tmt.usercenter.web.domain.TmtApproval;
import tmt.usercenter.web.domain.TmtRole;

import java.util.List;

public interface ITmtApprovalRepo extends ITmtBaseRepo<TmtApproval, Long> {

	List<TmtApproval> findByTmtUserId(Long id);

	@Query("select t from TmtApproval t where t.tmtUser.username = :username and t.originSystem.clientId = :clientId")
	List<TmtApproval> findByUsernameAndClientId(@Param("username") String username, @Param("clientId") String clientId);

	@Query("select t from TmtApproval t where t.tmtUser.username=:username and t.originSystem.clientId=:clientId and t.scope=:scope")
	List<TmtApproval> findByUsernameAndClientIdAndScope(@Param("username") String username, @Param("clientId") String clientId, @Param("scope") String scope);
}
